<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of EmailUtil
 *
 * @author Sorasak Siangsanan
 */
class EmailUtil {

    const HEADER_REGISTER = 'Welcome to tongdiviner.com';

    public static function sendEmail($receiver, $subject, $message) {
        $headers = "From: noreply\r\n";
        $headers .= "Reply-To: " . Yii::app()->params['adminEmail'] . "\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=utf-8\r\n";
        mail($receiver, $subject, $message, $headers);
    }

    public static function getRegisterMessage($email) {

        $customer = Customer::model()->findByAttributes(array('email' => $email));

        $msg = "<html><body>";
        $msg .= "<h3>Welcome " . $customer->Name . ' ' . $customer->Surname . "</h3>";
        $msg .= "<p>Your username : " . $email . "</p>";
        $msg .= "<p>Link to Activate User : <a target='_blank' href='" . Yii::app()->getBaseUrl(true) . "/index.php?r=register/activate&id=" . $customer->id . "&key=" . $customer->activate_key . "'>" . Yii::t('register', 'click') . "</a></p>";
        $msg .= "</body></html>";
        return $msg;
    }

}
